# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : p23.py
# @Time     : 2024/5/12 18:41
# @Author   : Robot-Zsj
"""
description:

小朋友来自多少小区


https://fcqian.blog.csdn.net/article/details/135119311?spm=1001.2014.3001.5502

i:
2 2 3

o:
7

"""
import math

nums = list(map(int, input().split()))


def getResult():
    cnts = {}

    for num in nums:
        cnts[num] = cnts.get(num, 0) + 1

    ans = 0
    for key in cnts.keys():
        total = key + 1
        ans = math.ceil(cnts[key] / total) * total
    return ans


print(getResult())
